<template>
    <div style="width: 100%;height: 100%;" v-loading="loading" element-loading-text="拼命加载中"
        element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.8)">
        <div style="width: 100%;height: 100%;">
            <div style="width: 100%;height: 9%;display: flex;align-items: center;">
                <div class="scrollable-div" ref="scrollableDiv" @wheel="scrollHorizontally">
                    <el-radio v-for="(item,index) in allForm" :key="index" v-model="radio1" :label="item.label" border>{{ returnTitle(index) }}</el-radio>
                </div>

                <div style="margin-left: auto;display: flex;gap:15px;">
                    <div style="display: flex; align-items: center; justify-content: center; width: 28px; "
                        class="btn_width">
                        <el-button style="width: 28px;height: 28px;" icon="el-icon-refresh-right"
                            @click="reNewDataAction()"></el-button>
                    </div>
                    <div class="btn_second">
                        <el-popover placement="top-start" title="标题" width="200" trigger="hover" content="新增一条管网至主控阀">
                            <el-button slot="reference" @click="add" icon="el-icon-plus">新增</el-button>
                        </el-popover>
                    </div>
                    <div class="btn_three">
                        <el-popover placement="top-start" title="标题" width="200" trigger="hover" content="删除所有选中的管网至主控阀">
                            <el-button slot="reference" @click="remove" icon="el-icon-delete">删除</el-button>
                        </el-popover>
                    </div>
                </div>
            </div>


            <div
                style="height: 84.5%;position: relative; overflow: auto;padding: 10px;border: 1px solid rgb(221, 228, 239);">
                <div style="display: flex;  align-items: center;">
                    <div class="before"></div>
                    <div >调压设施</div>
                    <div style="display: flex;margin-left: auto;align-items: center;gap: 15px;width: 40%;">
                        <div >备注</div>
                        <el-input v-model="allForm[radio1].data.notes.content" placeholder="请输入" style="width: 90%;"></el-input>


                    </div>
                </div>


                <div class="contentPadding" style="width: 100%; display: flex; flex-wrap: wrap;gap: 1%;">
                    <div style="border-radius: 4px;border: 1px solid #DCDFE6;margin-top: 20px;width: 19.2%;height: 202px;"
                        v-for="(item, index) in allForm[radio1].data.controllPressureDeviceImage" :key="index">
                        <div style="display: flex; padding: 10px;padding-left: 30px;align-items: center;">
                            <div
                                style="width: 4px;height: 15px;background-color: rgb(24, 144, 255);margin-right: 5px;border-radius: 2px;">
                            </div>
                            <div>{{ item.title }}</div>
                        </div>
                        <div style="width: 100%;height: 0.5px;background-color: rgb(220, 223, 230);"></div>
                        <div style="width: 100%;justify-content: center;padding: 20px;padding-left: 33px; ">

                            <div style="display: flex;gap:25px;text-align: center;">

                                <div style="width: 120px;height: 120px;position: relative;" class="demo-image__error">
                                    <el-image v-show="controllPressureDeviceImage[index].imageAddress.length > 0"
                                        style="width: 100%;height: 100%;"
                                        :src="controllPressureDeviceImage[index].imageAddress[0]"
                                        :preview-src-list="controllPressureDeviceImage[index].imageAddress">
                                        <div slot="error" class="image-slot">
                                            <img src="../../assets/images/stageIcon/加载失败.jpeg" alt=""
                                                style="width: 100%;height: 100%;">
                                        </div>
                                    </el-image>
                                    <img v-show="controllPressureDeviceImage[index].imageAddress.length == 0"
                                        src="../../assets/images/stageIcon/暂无图片.png" alt=""
                                        style="width: 100%;height: 100%;">
                                    <div class="imageSample"
                                        v-show="controllPressureDeviceImage[index].imageAddress.length > 0">范例图</div>
                                </div>
                                <div style="width: 120px;height: 120px;">
                                    <imageLookFifth :upAddress="item.upAddress" :imageData="item.imageData"
                                        :projectInfo="projectInfo" :id="stageSurveyPrfList[radio1].id"
                                        :dictName="item.dictName" :sampleImageAll="controllPressureDeviceImage"
                                        :imageIndex="index" :flieName="item.title"></imageLookFifth>

                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="titleStyle">
                    <div class="inputHorizon" v-for="item in allForm[radio1].data.controllPressureDevice" :key="item.id">
                        <div style="width: 112px;text-align: right;margin-right: 20px;">{{ item.name }}</div>
                        <div style="width:56%" v-if="item.componentType == false">
                            <el-select v-model="item.content" :placeholder="item.placeholder" style="width: 100%;" clearable>
                                <el-option v-for="items in item.data" :key="items.id" :label="items.name" :value="items.id">
                                </el-option>
                            </el-select>
                        </div>

                        <el-input v-if="item.componentType == true" v-model="item.content" :placeholder="item.placeholder"
                            style="width: 56%" clearable @input="restrictNumericInput"></el-input>

                    </div>
                </div>
                <div style="display: flex;  align-items: center;">
                    <div class="before"></div>
                    <div style="width: 93%;">现场情况</div>

                </div>

                <div class="contentPadding" style="width: 100%; display: flex; flex-wrap: wrap;gap: 1%;">
                    <div style="border-radius: 4px;border: 1px solid #DCDFE6;margin-top: 20px;width: 19.2%;height: 202px;"
                        v-for="(item, index) in allForm[radio1].data.currentSituation" :key="index">
                        <div style="display: flex; padding: 10px;padding-left: 30px;align-items: center;">
                            <div
                                style="width: 4px;height: 15px;background-color: rgb(24, 144, 255);margin-right: 5px;border-radius: 2px;">
                            </div>
                            <div>{{ item.title }}</div>
                        </div>
                        <div style="width: 100%;height: 0.5px;background-color: rgb(220, 223, 230);"></div>
                        <div style="width: 100%;justify-content: center;padding: 20px;padding-left: 33px; ">

                            <div style="display: flex;gap:25px;text-align: center;">

                                <div style="width: 120px;height: 120px;position: relative;" class="demo-image__error">
                                    <el-image v-show="currentSituation[index].imageAddress.length > 0"
                                        style="width: 100%;height: 100%;" :src="currentSituation[index].imageAddress[0]"
                                        :preview-src-list="currentSituation[index].imageAddress">
                                        <div slot="error" class="image-slot">
                                            <img src="../../assets/images/stageIcon/加载失败.jpeg" alt=""
                                                style="width: 100%;height: 100%;">
                                        </div>
                                    </el-image>
                                    <img v-show="currentSituation[index].imageAddress.length == 0"
                                        src="../../assets/images/stageIcon/暂无图片.png" alt=""
                                        style="width: 100%;height: 100%;">
                                    <div class="imageSample" v-show="currentSituation[index].imageAddress.length > 0">范例图
                                    </div>
                                </div>
                                <div style="width: 120px;height: 120px;">
                                    <imageLookFifth :upAddress="item.upAddress" :imageData="item.imageData"
                                        :projectInfo="projectInfo" :id="stageSurveyPrfList[radio1].id"
                                        :dictName="item.dictName" :sampleImageAll="currentSituation" :imageIndex="index" :flieName="item.title">
                                    </imageLookFifth>

                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <el-button class="buttonStyle" @click="submit">保存</el-button>
        </div>
    </div>
</template>
<script>
import { updateSurveyApi } from "@/api/project/survey";
import { getInfo } from "@/api/project/info";
import { controllPressureDevice, addControllPressureDevice, removeControllPressureDevice } from "@/api/project/stageApi";
import imageLookFifth from "../OtherOwerUseComponent/imageLookFifth.vue";
import { getTemplateFileListApi } from "@/api/project/file";
export default {
    components: {
        imageLookFifth
    },
    created() {
        const projectId = this.$route.params && this.$route.params.projectId;
        this.getInfo(projectId);
    },
    props: ['jsonData', 'imageData', 'projectInfo'],
    watch: {
        projectInfo: {
            handler(newData, oldData) {
                ///获取基本信息
                this.getData()
            },

        },
        // jsonData: {
        //     handler(newData, oldData) {
        //         // 这里可以调用您的方法，例如:
        //         this.runMethod(newData);
        //     },
        //     immediate: true // 立即触发一次，以便在初始值传递时也能运行方法
        // }
    },
    data() {
        return {
            loading: false,
            currentSituation: [
                // { id: 0, title: "现场照片", imageAddress: [], upAddress: '勘察范例/调压设施/现场情况/现场情况无隐患', imageData: {}, imageHint: '现场照片', description: '沉降描述', content: null, dictName: 'sceneNoHiddenDangers' },
                { id: 1, title: "门锁损坏", imageAddress: [], upAddress: '勘察范例/调压设施/现场情况/门锁损坏', imageData: {}, imageHint: '隐患图片', description: '沉降描述', content: null, dictName: 'damagedDoorLock' },
                { id: 2, title: "箱体、支架损坏生锈", imageAddress: [], upAddress: '勘察范例/调压设施/现场情况/箱体、支架损坏生锈', imageData: {}, imageHint: '隐患图片', description: '管道暴露描述', content: null, dictName: 'boxSupportDamagedRusted' },
                { id: 3, title: "调压柜(箱)门受影响", imageAddress: [], upAddress: '勘察范例/调压设施/现场情况/调压柜(箱)门受影响', imageData: {}, imageHint: '隐患图片', description: '施工工地描述', content: null, dictName: 'surgeTankDoorAffected' },
                { id: 4, title: "过滤器杂质过多", imageAddress: [], upAddress: '勘察范例/调压设施/现场情况/过滤器杂质过多', imageData: {}, imageHint: '隐患图片', description: '植被描述', content: null, dictName: 'excessiveImpuritiesFilter' },
                { id: 5, title: "压力表异常", imageAddress: [], upAddress: '勘察范例/调压设施/现场情况/压力表异常', imageData: {}, imageHint: '隐患图片', description: '重型机械碾压描述', content: null, dictName: 'abnormalPressureGauge' },
                { id: 6, title: "电磁阀走线不规范无有效连接", imageAddress: [], upAddress: '勘察范例/调压设施/现场情况/电磁阀走线不规范无有效连接', imageData: {}, imageHint: '隐患图片', description: '容易触碰地方描述', content: null, dictName: 'electromagneticValveWiring' },
            ],
            controllPressureDeviceImage: [
                { id: 0, title: "现场照片", imageAddress: [], upAddress: '勘察范例/调压设施/调压设施/现场照片', imageData: {}, imageHint: '现场照片', description: '沉降描述', content: null, dictName: 'noHiddenDangers' },
                { id: 1, title: "立管占压", imageAddress: [], upAddress: '勘察范例/调压设施/调压设施/立管占压', imageData: {}, imageHint: '隐患图片', description: '沉降描述', content: null, dictName: 'riserPressure' },
                { id: 2, title: "立管生锈", imageAddress: [], upAddress: '勘察范例/调压设施/调压设施/立管生锈', imageData: {}, imageHint: '隐患图片', description: '管道暴露描述', content: null, dictName: 'riserRusted' },
                { id: 3, title: "立管防腐脱落", imageAddress: [], upAddress: '勘察范例/调压设施/调压设施/立管防腐脱落', imageData: {}, imageHint: '隐患图片', description: '施工工地描述', content: null, dictName: 'riserAnticorrosiveFallOff' },
                { id: 4, title: "生锈", imageAddress: [], upAddress: '勘察范例/调压设施/调压设施/生锈', imageData: {}, imageHint: '隐患图片', description: '植被描述', content: null, dictName: 'rust' },
                { id: 5, title: "泄漏", imageAddress: [], upAddress: '勘察范例/调压设施/调压设施/泄漏', imageData: {}, imageHint: '隐患图片', description: '重型机械碾压描述', content: null, dictName: 'leakage' },
                { id: 6, title: "软管变形(沉降)", imageAddress: [], upAddress: '勘察范例/调压设施/调压设施/软管变形(沉降)', imageData: {}, imageHint: '隐患图片', description: '容易触碰地方描述', content: null, dictName: 'hoseDeformation' },
            ],
            input: '',
            checked: '',
            stageSurveyPrfList: [],
            ///全部内容做成一个数组
            allForm: [

            ],
            ///单选框的使用变量
            radio1: 0,
        }
    },
    name: "controllPressureDevice",
    methods: {
        returnTitle(index){
            
            if (this.allForm[index].data.notes.content!=null){
                return this. allForm[index].data.notes.content
            }
            return '调压设施'+(index+1) 
        },
        getData() {
            this.loading = true
            controllPressureDevice(this.projectInfo.projectId).then(response => {
                if (response.code == 200) {
                    this.loading = false
                    this.stageSurveyPrfList = response.data
                 
                    this.distrbute()

                }
            })
        },
        reNewDataAction() {

            this.getImage('勘察范例/调压设施/调压设施', 1)
            this.getImage('勘察范例/调压设施/现场情况', 2)
            this.getData()
        },
        getImage(path, action) {
            if (action == 1) {
                let controllPressureDeviceImage = [
                    { id: 0, title: "现场照片", imageAddress: [], upAddress: '勘察范例/调压设施/调压设施/现场照片', imageData: {}, imageHint: '现场照片', description: '沉降描述', content: null, dictName: 'noHiddenDangers' },
                    { id: 1, title: "立管占压", imageAddress: [], upAddress: '勘察范例/调压设施/调压设施/立管占压', imageData: {}, imageHint: '隐患图片', description: '沉降描述', content: null, dictName: 'riserPressure' },
                    { id: 2, title: "立管生锈", imageAddress: [], upAddress: '勘察范例/调压设施/调压设施/立管生锈', imageData: {}, imageHint: '隐患图片', description: '管道暴露描述', content: null, dictName: 'riserRusted' },
                    { id: 3, title: "立管防腐脱落", imageAddress: [], upAddress: '勘察范例/调压设施/调压设施/立管防腐脱落', imageData: {}, imageHint: '隐患图片', description: '施工工地描述', content: null, dictName: 'riserAnticorrosiveFallOff' },
                    { id: 4, title: "生锈", imageAddress: [], upAddress: '勘察范例/调压设施/调压设施/生锈', imageData: {}, imageHint: '隐患图片', description: '植被描述', content: null, dictName: 'rust' },
                    { id: 5, title: "泄漏", imageAddress: [], upAddress: '勘察范例/调压设施/调压设施/泄漏', imageData: {}, imageHint: '隐患图片', description: '重型机械碾压描述', content: null, dictName: 'leakage' },
                    { id: 6, title: "软管变形(沉降)", imageAddress: [], upAddress: '勘察范例/调压设施/调压设施/软管变形(沉降)', imageData: {}, imageHint: '隐患图片', description: '容易触碰地方描述', content: null, dictName: 'hoseDeformation' },
                ]
                this.controllPressureDeviceImage = controllPressureDeviceImage
                getTemplateFileListApi(path).then(response => {


                    if (response.code == 200) {
                        if (response.data.length != 0) {

                            Array.from(response.data).forEach(item => {
                             

                                for (var i = 0; i < this.controllPressureDeviceImage.length; i++) {

                                    if (this.controllPressureDeviceImage[i].upAddress == item.fileTreePath) {
                                        Array.from(item.fileList).forEach(items => {
                                            this.controllPressureDeviceImage[i].imageAddress.push(this.$myGlobalVariable + items)
                                        })
                                    }
                                }

                            }

                            );

                        }
                        
                    }
                })
            } else if (action == 2) {
                let currentSituation = [
                    // { id: 0, title: "现场照片", imageAddress: [], upAddress: '勘察范例/调压设施/现场情况/现场情况无隐患', imageData: {}, imageHint: '现场照片', description: '沉降描述', content: null, dictName: 'sceneNoHiddenDangers' },
                    { id: 1, title: "门锁损坏", imageAddress: [], upAddress: '勘察范例/调压设施/现场情况/门锁损坏', imageData: {}, imageHint: '隐患图片', description: '沉降描述', content: null, dictName: 'damagedDoorLock' },
                    { id: 2, title: "箱体、支架损坏生锈", imageAddress: [], upAddress: '勘察范例/调压设施/现场情况/箱体、支架损坏生锈', imageData: {}, imageHint: '隐患图片', description: '管道暴露描述', content: null, dictName: 'boxSupportDamagedRusted' },
                    { id: 3, title: "调压柜(箱)门受影响", imageAddress: [], upAddress: '勘察范例/调压设施/现场情况/调压柜(箱)门受影响', imageData: {}, imageHint: '隐患图片', description: '施工工地描述', content: null, dictName: 'surgeTankDoorAffected' },
                    { id: 4, title: "过滤器杂质过多", imageAddress: [], upAddress: '勘察范例/调压设施/现场情况/过滤器杂质过多', imageData: {}, imageHint: '隐患图片', description: '植被描述', content: null, dictName: 'excessiveImpuritiesFilter' },
                    { id: 5, title: "压力表异常", imageAddress: [], upAddress: '勘察范例/调压设施/现场情况/压力表异常', imageData: {}, imageHint: '隐患图片', description: '重型机械碾压描述', content: null, dictName: 'abnormalPressureGauge' },
                    { id: 6, title: "电磁阀走线不规范无有效连接", imageAddress: [], upAddress: '勘察范例/调压设施/现场情况/电磁阀走线不规范无有效连接', imageData: {}, imageHint: '隐患图片', description: '容易触碰地方描述', content: null, dictName: 'electromagneticValveWiring' },
                ]

                this.currentSituation = currentSituation
                getTemplateFileListApi(path).then(response => {


                    if (response.code == 200) {
                        if (response.data.length != 0) {

                            Array.from(response.data).forEach(item => {
                        

                                for (var i = 0; i < this.currentSituation.length; i++) {

                                    if (this.currentSituation[i].upAddress == item.fileTreePath) {
                                        Array.from(item.fileList).forEach(items => {
                                            this.currentSituation[i].imageAddress.push(this.$myGlobalVariable + items)
                                        })
                                    }
                                }

                            }

                            );

                        }

                    }
                })
            }
        },
        getInfo(projectId) {
            getInfo(projectId).then(response => {
                this.projectInfo = response.data;
            })
        },
        reNew() {
            ///获取基本信息
            controllPressureDevice(this.projectInfo.projectId).then(response => {
                if (response.code == 200) {

                    this.stageSurveyPrfList = response.data
                    this.distrbute()

                }
            })
        },
        renew() {

        },
        distrbute() {
            this.allForm = []
            for (let i = 0; i < this.stageSurveyPrfList.length; i++) {
                let controllPressureDeviceImage = [
                    { id: 0, title: "现场照片", imageAddress: [], upAddress: '调压设施/调压设施/现场照片', imageData: {}, imageHint: '现场照片', description: '沉降描述', content: null, dictName: 'noHiddenDangers' },
                    { id: 1, title: "立管占压", imageAddress: [], upAddress: '调压设施/调压设施/立管占压', imageData: {}, imageHint: '隐患图片', description: '沉降描述', content: null, dictName: 'riserPressure' },
                    { id: 2, title: "立管生锈", imageAddress: [], upAddress: '调压设施/调压设施/立管生锈', imageData: {}, imageHint: '隐患图片', description: '管道暴露描述', content: null, dictName: 'riserRusted' },
                    { id: 3, title: "立管防腐脱落", imageAddress: [], upAddress: '调压设施/调压设施/立管防腐脱落', imageData: {}, imageHint: '隐患图片', description: '施工工地描述', content: null, dictName: 'riserAnticorrosiveFallOff' },
                    { id: 4, title: "生锈", imageAddress: [], upAddress: '调压设施/调压设施/生锈', imageData: {}, imageHint: '隐患图片', description: '植被描述', content: null, dictName: 'rust' },
                    { id: 5, title: "泄漏", imageAddress: [], upAddress: '调压设施/调压设施/泄漏', imageData: {}, imageHint: '隐患图片', description: '重型机械碾压描述', content: null, dictName: 'leakage' },
                    { id: 6, title: "软管变形(沉降)", imageAddress: [], upAddress: '调压设施/调压设施/软管变形(沉降)', imageData: {}, imageHint: '隐患图片', description: '容易触碰地方描述', content: null, dictName: 'hoseDeformation' },
                ]
                for (let n = 0; n < controllPressureDeviceImage.length; n++) {
                    controllPressureDeviceImage[n].content = this.stageSurveyPrfList[i][controllPressureDeviceImage[n].dictName]
                }

                let controllPressureDevice = [
                    { name: '调压箱数', id: 1, componentType: true, content: null, placeholder: "请输入(数量)", dictName: 'regulatorBoxNum', isNumTypeInput: true },
                    { name: '调压柜数', id: 2, componentType: true, content: null, placeholder: "请输入(数量)", dictName: 'surgeTankNum', isNumTypeInput: true },
                    {
                        name: '调压箱', id: 3, componentType: false, content: null, placeholder:'立式/柜式/靠墙/独立',dictName: 'regulatorBox', data: [
                            { name: '立式', id: 1 },
                            { name: '柜式', id: 2 },
                            { name: '靠墙', id: 3 },
                            { name: '独立', id: 4 },
                        ]
                    },
                    {
                        name: '电磁切断阀', id: 4, componentType: false, content: null,placeholder:'有配置/没有配置', dictName: 'electromagneticShutOffValve', data: [
                            { name: '有配置', id: 1 },
                            { name: '没有配置', id: 2 },
                        ]
                    },
                    {
                        name: '电磁切断阀情况', id: 5, componentType: false, content: null,placeholder:'正常/异常', dictName: 'equipmentSituation', data: [
                            { name: '正常', id: 1 },
                            { name: '异常', id: 2 },
                        ]
                    },
                    { name: '电磁切断阀通电情况', id: 6, componentType: true, content: null, placeholder: "请输入", dictName: 'powerOnCondition', isNumTypeInput: false },
                    { name: '电磁切断阀使用情况', id: 7, componentType: true, content: null, placeholder: "请输入", dictName: 'useCase', isNumTypeInput: false },
                    { name: '输入端阀门类型', id: 8, componentType: true, content: null, placeholder: "请输入", dictName: 'inputValveType', isNumTypeInput: false },
                    { name: '输入端阀门口径', id: 9, componentType: true, content: null, placeholder: "请输入", dictName: 'inputValveDiameter', isNumTypeInput: false },
                    { name: '输出端阀门类型', id: 10, componentType: true, content: null, placeholder: "请输入", dictName: 'outputValveType', isNumTypeInput: false },
                    { name: '输出端阀门口径', id: 11, componentType: true, content: null, placeholder: "请输入", dictName: 'outputValveDiameter', isNumTypeInput: false },
                    { name: '调压器公称流量', id: 12, componentType: true, content: null, placeholder: "请输入", dictName: 'nominalFlowRateOfVoltageRegulator', isNumTypeInput: false },
                    { name: '调压器进口压力范围', id: 13, componentType: true, content: null, placeholder: "请输入", dictName: 'inletPressureRange', isNumTypeInput: false },
                    { name: '调压器实际进口压力值', id: 14, componentType: true, content: null, placeholder: "请输入", dictName: 'actualInletPressureValue', isNumTypeInput: false },
                    { name: '调压器出口压力范围', id: 15, componentType: true, content: null, placeholder: "请输入", dictName: 'outletPressureRange', isNumTypeInput: false },
                    { name: '调压器实际出口压力值', id: 16, componentType: true, content: null, placeholder: "请输入", dictName: 'actualOutletPressureValue', isNumTypeInput: false },
                    { name: '调压柜进口数', id: 17, componentType: true, content: null, placeholder: "请输入(数量)", dictName: 'surgeTankInputNum', isNumTypeInput: true },
                    { name: '调压柜出口数', id: 18, componentType: true, content: null, placeholder: "请输入(数量)", dictName: 'surgeTankOutletNum', isNumTypeInput: true },
                    { name: '进口阀门类型', id: 19, componentType: true, content: null, placeholder: "请输入", dictName: 'importedValveType', isNumTypeInput: false },
                    { name: '进口阀门中压压力', id: 20, componentType: true, content: null, placeholder: "请输入", dictName: 'mediumPressureOfInletValve', isNumTypeInput: false },
                    { name: '进口阀门口径', id: 21, componentType: true, content: null, placeholder: "请输入", dictName: 'inletValveDiameter', isNumTypeInput: false },
                    { name: '出口阀门类型', id: 22, componentType: true, content: null, placeholder: "请输入", dictName: 'outletValveType', isNumTypeInput: false },
                    { name: '出口阀门低压压力', id: 23, componentType: true, content: null, placeholder: "请输入", dictName: 'lowPressureOfOutletValve', isNumTypeInput: false },
                    { name: '出口阀门口径', id: 24, componentType: true, content: null, placeholder: "请输入", dictName: 'outletValveDiameter', isNumTypeInput: false },
                    { name: '阀门压差值', id: 25, componentType: true, content: null, placeholder: "请输入", dictName: 'pressureDifference', isNumTypeInput: false },
                    { name: '流量计品牌', id: 26, componentType: true, content: null, placeholder: "请输入", dictName: 'flowmeterBrand', isNumTypeInput: false },
                    { name: '流量计型号', id: 27, componentType: true, content: null, placeholder: "请输入", dictName: 'flowmeterModel', isNumTypeInput: false },
                    { name: '压力远传数', id: 28, componentType: true, content: null, placeholder: "请输入", dictName: 'remotePressureTransmission', isNumTypeInput: false },
                    { name: '泄漏监测数', id: 29, componentType: true, content: null, placeholder: "请输入", dictName: 'leakageMonitoring', isNumTypeInput: false },

                ]
                for (let n = 0; n < controllPressureDevice.length; n++) {
                    if (controllPressureDevice[n].componentType == true) {
                        controllPressureDevice[n].content = this.stageSurveyPrfList[i][controllPressureDevice[n].dictName]
                    } else {
                        let value = this.stageSurveyPrfList[i][controllPressureDevice[n].dictName]
                        if (value != null && value != '') {
                            controllPressureDevice[n].content = parseInt(this.stageSurveyPrfList[i][controllPressureDevice[n].dictName])
                        }
                    }
                }

                let currentSituation = [
                 
                    { id: 1, title: "门锁损坏", imageAddress: [], upAddress: '调压设施/现场情况/门锁损坏', imageData: {}, imageHint: '隐患图片', description: '沉降描述', content: null, dictName: 'damagedDoorLock' },
                    { id: 2, title: "箱体、支架损坏生锈", imageAddress: [], upAddress: '调压设施/现场情况/箱体、支架损坏生锈', imageData: {}, imageHint: '隐患图片', description: '管道暴露描述', content: null, dictName: 'boxSupportDamagedRusted' },
                    { id: 3, title: "调压柜(箱)门受影响", imageAddress: [], upAddress: '调压设施/现场情况/调压柜(箱)门受影响', imageData: {}, imageHint: '隐患图片', description: '施工工地描述', content: null, dictName: 'surgeTankDoorAffected' },
                    { id: 4, title: "过滤器杂质过多", imageAddress: [], upAddress: '调压设施/现场情况/过滤器杂质过多', imageData: {}, imageHint: '隐患图片', description: '植被描述', content: null, dictName: 'excessiveImpuritiesFilter' },
                    { id: 5, title: "压力表异常", imageAddress: [], upAddress: '调压设施/现场情况/压力表异常', imageData: {}, imageHint: '隐患图片', description: '重型机械碾压描述', content: null, dictName: 'abnormalPressureGauge' },
                    { id: 6, title: "电磁阀走线不规范无有效连接", imageAddress: [], upAddress: '调压设施/现场情况/电磁阀走线不规范无有效连接', imageData: {}, imageHint: '隐患图片', description: '容易触碰地方描述', content: null, dictName: 'electromagneticValveWiring' },
                ]
                let notes =
                    { dictName: 'notes', placeholder: '请输入', isNumTypeInput: false, content: null }
                notes.content = this.stageSurveyPrfList[i].notes
                var dict = { data: {}, label: this.allForm.length }
                dict.data['controllPressureDeviceImage'] = controllPressureDeviceImage
                dict.data['controllPressureDevice'] = controllPressureDevice
                dict.data['currentSituation'] = currentSituation
                dict.data['notes'] = notes
                this.allForm.push(dict)




            }
            this.getImage('勘察范例/调压设施/调压设施', 1)
            this.getImage('勘察范例/调压设施/现场情况', 2)
        },
        ///删除表单操作
        remove() {
            if (this.allForm.length > 1) {

                ///删除操作

                let id = this.stageSurveyPrfList[this.radio1].id
                removeControllPressureDevice(id).then(response => {
                    if (response.code == 200) {
                        if (this.radio1 == this.allForm.length - 1) {
                            this.radio1 = this.radio1 - 1

                        }
                        this.reNew()
                    }
                })




            }
        },
        ///添加新的表单
        add() {

            let stageSurvey = { projectId: this.projectInfo.projectId }


            addControllPressureDevice(stageSurvey).then(response => {
                if (response.code == 200) {
                    this.reNew()
                }

            })


            // var dict = { data: {}, label: this.allForm.length }
            // dict.data['controllPressureDeviceImage'] = controllPressureDeviceImage
            // dict.data['controllPressureDevice'] = controllPressureDevice
            // dict.data['currentSituation'] = currentSituation

            // dict.data['mainControllValveImage'] = netStillMainControllValueOne
            // dict.data['inWellDecription'] = description

            // this.allForm.push(dict)
        },
        ///横向滚动功能
        scrollHorizontally(event) {
            event.preventDefault();
            const scrollAmount = event.deltaY;
            this.$refs.scrollableDiv.scrollLeft += scrollAmount;
        },
        open() {
            this.$alert('提交调压设施成功', '提交成功', {
                confirmButtonText: '确定',

            });
        },
        restrictNumericInput(item) {
            const value = item.content;

            // 使用正则表达式验证输入是否为数字
            if (!/^\d*$/.test(value)) {
                // 如果输入不是数字，则移除非数字字符
                if (item.isNumTypeInput == true) {
                    item.content = value.replace(/[^\d]/g, '');
                }

            }
        },
        runMethod(newData) {

            for (var i = 0; i < this.controllPressureDevice.length; i++) {

                if (newData.hasOwnProperty(this.controllPressureDevice[i].dictName)) {
                    if (this.controllPressureDevice[i].componentType == true) {
                        this.controllPressureDevice[i].content = newData[this.controllPressureDevice[i].dictName]
                    } else {
                        let value = Number(newData[this.controllPressureDevice[i].dictName])
                        if (value != 0) {
                            this.controllPressureDevice[i].content = value
                        }
                    }
                }

            }

        },
        submit() {
            this.loading = true

            //修改已有的
            let all = { stageSurveyPrfList: [] }
            for (let i = 0; i < this.stageSurveyPrfList.length; i++) {


                var stageSurvey = { projectId: this.projectInfo.projectId, id: this.stageSurveyPrfList[i].id }




                //调压设施
                for (let n = 0; n < this.allForm[i].data['controllPressureDevice'].length; n++) {

                    if (this.allForm[i].data['controllPressureDevice'][n].dictName != '') {
                        stageSurvey[this.allForm[i].data['controllPressureDevice'][n].dictName] = this.allForm[i].data['controllPressureDevice'][n].content
                    }
                }
                if (this.allForm[i].data['notes'].dictName != '') {
                    stageSurvey[this.allForm[i].data['notes'].dictName] = this.allForm[i].data['notes'].content
                }


                all.stageSurveyPrfList.push(stageSurvey)
            }
          
            updateSurveyApi(all).then(response => {
                this.loading = false
                if (response.code == 200) {
                    this.open()
                }
            })

        }
    }
}
</script>
<style></style>
